package com.usian.security.exception;

import com.usian.common.model.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * ClassName: GlobalExceptionHandler
 * Author:   WGG
 * Date:    2022-12-2022/12/21-16:14
 * Version: 1.0
 * Description:
 */
@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {

    @ExceptionHandler(value = CustomException.class)
    @ResponseStatus(HttpStatus.BAD_REQUEST)
    public Result handler(CustomException customException){
        log.error("运行时异常--------->:",customException);
        return Result.createError(customException.getMessage());
    }
}
